# coding = utf-8

names = [1, 2]
data = {"linshi": "01", "linshi01": "02"}

# print(names[3])
# print(data['name'])

# 一
try:
    print(names[3])
    print(data['name'])
except KeyError as e:
    print("没有这个key：", e)
except IndexError as e:
    print("没有这个字典值：", e)

# 二
try:
    print(names[3])
    print(data['name'])
except (KeyError,IndexError) as e:
    print("没有这个key：", e)
except Exception as e:
    print("没有这个字典值：", e)


# else的使用  ---------------
try:
    print(names[3])
except (KeyError, IndexError) as e:
    print("没有这个key：", e)
except Exception as e:
    print("没有这个字典值：", e)
else:
    print("nothing error")


# finally的使用  ---------------
# try:
#     print(names[3])
# except (KeyError, IndexError) as e:
#     print("没有这个key：", e)
# except Exception as e:
#     print("没有这个字典值：", e)
# else:
#     print("nothing error")
# finally:
#     print("咋着都会执行")









